package top.revery.datasource.service;

import org.springframework.web.bind.annotation.RestController;
import top.revery.api.api.category.ICategoryApi;
import top.revery.api.entity.other.BaseCategory;
import top.revery.datasource.util.dsource;

import java.util.List;

/**
 * <h1> ---  --- </h1>
 * Created by  revery.top jun
 * Date  2019-12-04 21:22
 */
@RestController
public class CategoryServiceController implements ICategoryApi {

    @Override
    public List<BaseCategory> getList(int parentID){

        List<BaseCategory> lists = dsource.categoryDto.findByParentID(parentID);

        return lists;
    }

    public BaseCategory save(BaseCategory baseCategory) {
        return dsource.categoryDto.save(baseCategory);
    }

    @Override
    public Boolean del(Long id) {
        try{
            dsource.categoryDto.deleteById(id);
        }catch (Exception e){
            return false;
        }
        return true;
    }
}
